package com.ruoyi.cbfa.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.cbfa.domain.AAddressListVo;
import com.ruoyi.cbfa.service.IAAddressListVoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 参保档案Controller
 * 
 * @author lgr
 * @date 2025-06-03
 */
@RestController
@RequestMapping("/cbda/cbda")
public class AAddressListVoController extends BaseController
{
    @Autowired
    private IAAddressListVoService addressListVoService;

    /**
     * 查询参保档案列表
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:list')")
    @GetMapping("/list")
    public TableDataInfo list(AAddressListVo AAddressListVo)
    {
        startPage();
        List<AAddressListVo> list = addressListVoService.selectAddressListVoList(AAddressListVo);
        return getDataTable(list);
    }

    /**
     * 导出参保档案列表
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:export')")
    @Log(title = "参保档案", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AAddressListVo AAddressListVo)
    {
        List<AAddressListVo> list = addressListVoService.selectAddressListVoList(AAddressListVo);
        ExcelUtil<AAddressListVo> util = new ExcelUtil<AAddressListVo>(AAddressListVo.class);
        util.exportExcel(response, list, "参保档案数据");
    }

    /**
     * 获取参保档案详细信息
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(addressListVoService.selectAddressListVoById(id));
    }

    /**
     * 新增参保档案
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:add')")
    @Log(title = "参保档案", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AAddressListVo AAddressListVo)
    {
        return toAjax(addressListVoService.insertAddressListVo(AAddressListVo));
    }

    /**
     * 修改参保档案
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:edit')")
    @Log(title = "参保档案", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AAddressListVo AAddressListVo)
    {
        return toAjax(addressListVoService.updateAddressListVo(AAddressListVo));
    }

    /**
     * 删除参保档案
     */
    @PreAuthorize("@ss.hasPermi('cbda:cbda:remove')")
    @Log(title = "参保档案", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(addressListVoService.deleteAddressListVoByIds(ids));
    }
}
